define(['hr.common'
, 'app/hrManagerRbac/dictionary/dictionary.model'
, 'app/mdSheQuHospitalBase/medicine/medicine.model'
], function(common
, Dictionary
, Medicine
){
    function InitModel(){
        var p = {
            url: '/stock/findAllByPage',
            param: '',
            //场景一：columns和operation中width字段值使用百分比，其总和为100%；
            //场景二：columns和operation中width字段值用固定像素值，比如'50px'
            columns: [
                [
                    {id: 'bid', width: '5%', text: '进价'},
                    {id: 'retailPrice', width: '7%', text: '余药零售价'},
                    {id: 'vipPrice', width: '7%', text: '余药会员售价'},
                    {id: 'payType.content', width: '7%', text: '付款方式'},
                    {id: 'payable', width: '7%', text: '应付金额'},
                    {id: 'payAmount', width: '7%', text: '实付金额'},
                    {id: 'purchaseDate', width: '9%', text: '进货时间', formatter:{fun:'formatDate',format:'YYYY-MM-DD'}},
                    {id: 'expirationDay', width: '5%', text: '保质天数'},
                    {id: 'expDate', width: '9%', text: '过期日期', formatter:{fun:'formatDate',format:'YYYY-MM-DD'}},
                    {id: 'purchaseTotal', width: '7%', text: '进货总数'},
                    {id: 'restTotal', width: '7%', text: '剩余数量'},
                    {id: 'medicine.medicineName', width: '7%', text: '药品'}
                ]
            ],
            operation: [
                {width: '5%',icon: 'icon-search',text: '详细', clickOperations: 'showData'},
                {width: '5%',icon: 'icon-pencil',text: '修改', clickOperations: 'updateData'},
                {width: '5%',icon: 'icon-cancel-2',text: '删除', clickOperations: 'deleteData'}
            ],
            pageItem: {'id': '10', 'text': '10'},
            title: '库存表列表'
        };
        var tableModel = common.createTableModel(p);
        var model  = {
            searchModel: {
                payType: ko.observable(''),
                purchaseDate: ko.observable(''),
                expDate: ko.observable(''),
                medicine: ko.observable()
            },
            tableModel: tableModel,
            dialogModel: {
                stockModel: {
                    id: ko.observable(''),
                    bid: ko.observable(''),
                    retailPrice: ko.observable(''),
                    vipPrice: ko.observable(''),
                    payType: ko.observable(''),
                    payable: ko.observable(''),
                    payAmount: ko.observable(0),
                    purchaseDate: ko.observable(''),
                    expirationDay: ko.observable(''),
                    expDate: ko.observable(''),
                    purchaseTotal: ko.observable(0),
                    restTotal: ko.observable(''),
                    medicine: ko.observable().extend({
                        required: {
                            message:'药品不允许为空'
                        }
                    })
                    /*
                    通过extend方法，添加对该字段的验证规则，下面示例表示，content字段必填且最大长度为20
                    content: ko.observable().extend({
                        required: {
                            message:'字典名称不允许为空'
                        },
                        maxLength: {
                            params: 20,
                            message:'字典说明长度不允许超过{0}'
                        }
                    })
                    */
                }
                , dictionaryArray: ko.observableArray()
                , medicineArray: ko.observableArray()
                , medicineAddArray: ko.observableArray(),
                medicine: ko.observable(),
                exchange: ko.observable(),
                factoryName: ko.observable(),
                datatimepicker: {
                    format:	'Y-m-d',
                    timepicker: false,
                    closeOnDateSelect: true
                }
            },
            datatimepicker: {
                format:	'Y-m-d',
                timepicker: false,
                closeOnDateSelect: true
            }
        };
        return model;
    }
    return InitModel;
});